<template>
  <div class="rent" >
    <van-nav-bar left-arrow @click-left="onClickLeft" fixed title="房屋管理" />
    <div class="house" v-if="isShow">

    <div class="myRent">
      <div class="img">
        <img
          src="https://img1.baidu.com/it/u=2566017301,1863866598&fm=253&fmt=auto&app=138&f=JPEG?w=748&h=500"
          alt=""
        />
        <p>你还没有房源，<span class="router" @click="show">点我去发布房源哦~~</span></p>
      </div>
    </div>

    </div>
    <huose-item  v-for="item in collectList"
        :key="item.id"
        :item="item"/>
  </div>
</template>

<script>

import { getPublishHouse } from '@/api/house'
import HuoseItem from '@/components/HuoseItem.vue'
export default {
  name: 'rent-page',
  components: { HuoseItem },
  data () {
    return {
      isShow: true,
      collectList: []
    }
  },
  methods: {
    onClickLeft () {
      this.$router.back()
    },
    show () {
      this.$router.push('/addHouse')
    }
  },
  async created () {
    const res = await getPublishHouse()
    console.log(res)
    const list = res.body
    list.forEach((item) => {
      item.houseImg = 'http://liufusong.top:8080' + item.houseImg
    })
    console.log(list)
    this.collectList = list
    if (res.status === 200) {
      this.isShow = false
    }
  }
}
</script>

<style lang="less" scoped>
.rent {
  margin-top: 50px;
  margin-bottom: 50px;
  .myRent {
    .img {
      margin: 0 auto;
      width: 260px;
      text-align: center;
      color: #ccc;
      font-size: 14px;
      .router {
        color: pink;
      }
    }
  }
}
</style>
